package com.phoenix.jsef.framework.accessfilter;

/**
 * @version V1.0
 * @ClassName: AccessFilterAddNewItem
 * @Description:TODO()
 * @author: 李启联
 * @date: 2018-08-16 09:47
 * @Copyright: Copyright (c), 2018-2018
 * 申明：本内容未经作者本人同意,禁止外泄以及用于其他的商业项目.
 */
public class AccessFilterAddNewItem extends AccessFilterItem{

    public boolean andCondition;
    public AccessFilter accessFilter;

    public boolean isAndCondition() {
        return andCondition;
    }

    public AccessFilterAddNewItem(boolean andCondition, AccessFilter accessFilter){
        super(andCondition, null, null);
        this.andCondition = andCondition;
        this.accessFilter = accessFilter;
    }

    public AccessFilterAddNewItem(AccessFilter accessFilter){
        super(true, null, null);
        this.andCondition = true;
        this.accessFilter = accessFilter;
    }

    public AccessFilter getFilter(){
        return accessFilter;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder( ( (andCondition) ? " AND (" : " OR (" ) + "'__PLACEHOLDER' = '__PLACEHOLDER'");
        for(int i = 0 ; i< accessFilter.filters.size();i++){
            AccessFilterItem item = (AccessFilterItem) accessFilter.filters.get(i) ;
            sb.append(item);
        }
        sb.append(") ");
        return sb.toString();
    }
}